/**
 * Project Name:springBoot-serviceImpl
 * File Name:PublishSubscribe.java
 * Package Name:com.libra.rabbitmq.publishSubscribe.serviceImp
 * Date:2018年8月20日下午6:57:40
 * Copyright (c) 2018, wangzhch All Rights Reserved.
 *
*/

package com.libra.rabbitmq.publishSubscribe.serviceImp;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.libra.model.mq.Teacher;
import com.libra.rabbitmq.config.QueueConstants;

/**
 * ClassName:PublishSubscribe <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason:	 TODO ADD REASON. <br/>
 * Date:     2018年8月20日 下午6:57:40 <br/>
 * @author   wangzhch
 * @version  
 * @since    JDK 1.8
 * @see 	 
 */
@Component
public class SendPublishSubscribeServiceImpl {
	Logger logger = LoggerFactory.getLogger(SendPublishSubscribeServiceImpl.class);
	
	@Autowired
	private AmqpTemplate amqpTemplate;
	
	public void publishSubscribe(Teacher teacher) {
		logger.info("发布订阅模式写入消息内容:{}",JSON.toJSONString(teacher));
		amqpTemplate.convertAndSend(QueueConstants.PS_MESSAGE_EXCHANGE,QueueConstants.PS_ROUTE_KEYA, teacher);
	}
}

